#import "SSBatteryInfo.h"
#import <UIKit/UIKit.h>
@implementation SSBatteryInfo
+ (float)batteryLevel {
    @try {
        UIDevice *device = [UIDevice currentDevice];
        device.batteryMonitoringEnabled = YES;
        float batteryLevel = 0.0;
        float batteryCharge = [device batteryLevel];
        if (batteryCharge > 0.0f) {
            batteryLevel = batteryCharge * 100;
        } else {
            return -1;
        }
        return batteryLevel;
    }
    @catch (NSException *exception) {
        return -1;
    }
}
+ (BOOL)charging {
    @try {
        UIDevice *device = [UIDevice currentDevice];
        device.batteryMonitoringEnabled = YES;
        if ([device batteryState] == UIDeviceBatteryStateCharging || [device batteryState] == UIDeviceBatteryStateFull) {
            return true;
        } else {
            return false;
        }
    }
    @catch (NSException *exception) {
        return false;
    }
}
+ (BOOL)fullyCharged {
    @try {
        UIDevice *device = [UIDevice currentDevice];
        device.batteryMonitoringEnabled = YES;
        if ([device batteryState] == UIDeviceBatteryStateFull) {
            return true;
        } else {
            return false;
        }
    }
    @catch (NSException *exception) {
        return false;
    }
}
@end
